package com.lmx.repoDomain.tmodel;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

// default package
import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 咨询表
 */
@Entity
@JsonApiResource(type = "consultinfo")
@Table(name = "tnb_consult_info")
// @JsonIgnoreProperties(value={"hibernateLazyInitializer","handler"})
public class ConsultInfo extends BaseEntity {

	private String abondonInfo;// 作废原因

	private Dicttype abondonReason;// 作废原因

	private String advTel;// 咨询人电话

	private String advContent;// 咨询内容

	private Integer advDate;// 咨询时间

	private Dicttype advGender;// 性别

	private Dicttype relationType;// 个人 夫妻

	private String advGoal;// 目的

	private String advName;// 咨询人姓名

	private List<Dicttype> advWay;// 获取途径 huibati

	private Integer appointmentDate;// 预约参观日期
	
	private Integer sign;

	private String care;// 重点关心

	private Dicttype consultChannel;// 咨询方式

	private Employee receiveStaff;// 接待人

	// private String channelDetAiled;

	private Integer createDateTime;// 创建日期

	private User createUser;//

	private String dietRequirements;// 饮食要求

	// private Dicttype diningStandard;//饮食标准

	private String discontent;// 不满意的地方

	private String customerAddr;//

	private String customerBrith;// 年龄 男

	private String customerCardCode;

	private String customerConsumingAbility;// 消费能力

	private String customerTel;

	private Dicttype customerEducation;

	private Dicttype customerGender;

	private String customerName;

	private Dicttype customerNative;// 籍贯

	private String customerPS;// 身体状况

	private Dicttype consultRelation;// 与老人关系

	private Dicttype customerSelfCareAbility;// 自理能力 男

	// private String incomeDate;

	private List<BackVistInfo> backVistInfos;// 回访

	private Integer lastUpdateDateTime;

	private User lastUpdateUser;

	private Dicttype customerNationality;// 民族

	private Dicttype nursingGrade;// 护理等级

	private String occupancyIntent;// 入住意向

	private Dicttype consultStatus;// 状态，0：新创建 1：已更新2：已预约 3：已试住4：已入住 5:退住99：废除

	private String otherRequirements;// 其他要求

	private String psychologicalPrice;// 期望价格

	private String review;// 参观后反映信息

	private String roomRequirements;// 房屋要求

	private String serviceRequirements;// 服务要求

	private Employee heartStaff;// 孝心助理

	private List<Dicttype> inPreference;// 入住偏好

	private Dicttype liveIntent;// 入住yixiang

	// private Dicttype status;// 状态，0：新创建 1：已更新2：已预约 3：已试住4：已入住 5:退住99：废除

	private String remark;// 备注

	private Customer customer;

	private Employee otherReceiveStaff;// 预约接待人

	private Integer backvistNum;

	private Dicttype roomType;
	private Dicttype dementiaType;// 失智程度

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "relation_type", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getRelationType() {
		return relationType;
	}

	public void setRelationType(Dicttype relationType) {
		this.relationType = relationType;
	}

	@Transient
	public Integer getBackvistNum() {
		return backvistNum;
	}

	public void setBackvistNum(Integer backvistNum) {
		if (backvistNum == null)
			backvistNum = 0;
		this.backvistNum = backvistNum;
	}

	@JsonApiToOne
	@ManyToOne
	@JoinColumn(name = "other_receive_staffid", foreignKey = @ForeignKey(name = "null"))
	public Employee getOtherReceiveStaff() {
		return otherReceiveStaff;
	}

	public void setOtherReceiveStaff(Employee otherReceiveStaff) {
		this.otherReceiveStaff = otherReceiveStaff;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "live_intent", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getLiveIntent() {
		return liveIntent;
	}

	public void setLiveIntent(Dicttype liveIntent) {
		this.liveIntent = liveIntent;
	}

	// @JsonApiToOne
	// @JsonApiIncludeByDefault
	// @ManyToOne(fetch = FetchType.LAZY)
	// @JoinColumn(name = "inpreference_id", foreignKey = @ForeignKey(name =
	// "null"))
	// @Fetch(FetchMode.JOIN) //huibati
	@JsonApiToMany
	@JsonApiIncludeByDefault
	@ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinTable(name = "tnb_consult_inpreference", joinColumns = { @JoinColumn(name = "consult_id",
			nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) },
			inverseJoinColumns = { @JoinColumn(name = "inpreference_id", nullable = false,
					updatable = false, foreignKey = @ForeignKey(name = "null")) })
	@Fetch(FetchMode.JOIN)
	public List<Dicttype> getInPreference() {
		return inPreference;
	}

	public void setInPreference(List<Dicttype> inPreference) {
		this.inPreference = inPreference;
	}

	// @JsonApiLookupIncludeAutomatically
	@JsonApiToMany
	@Fetch(FetchMode.JOIN)
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "consultInfo")
	public List<BackVistInfo> getBackVistInfos() {
		return backVistInfos;
	}

	public void setBackVistInfos(List<BackVistInfo> backVistInfos) {
		this.backVistInfos = backVistInfos;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "abondon_info")
	public String getAbondonInfo() {
		return abondonInfo;
	}

	public void setAbondonInfo(String abondonInfo) {
		this.abondonInfo = abondonInfo;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "abondon_id", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getAbondonReason() {
		return abondonReason;
	}

	public void setAbondonReason(Dicttype abondonReason) {
		this.abondonReason = abondonReason;
	}

	@Column(name = "consult_tel")
	public String getAdvTel() {
		return advTel;
	}

	public void setAdvTel(String advTel) {
		this.advTel = advTel;
	}

	@Column(name = "consult_content")
	public String getAdvContent() {
		return advContent;
	}

	public void setAdvContent(String advContent) {
		this.advContent = advContent;
	}

	@Column(name = "consult_time")
	public Integer getAdvDate() {
		return advDate;
	}

	public void setAdvDate(Integer advDate) {
		this.advDate = advDate;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "consult_genderid", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getAdvGender() {
		return advGender;
	}

	public void setAdvGender(Dicttype advGender) {
		this.advGender = advGender;
	}

	@Column(name = "consult_goal")
	public String getAdvGoal() {
		return advGoal;
	}

	public void setAdvGoal(String advGoal) {
		this.advGoal = advGoal;
	}

	@Column(name = "consult_name")
	public String getAdvName() {
		return advName;
	}

	public void setAdvName(String advName) {
		this.advName = advName;
	}

	// @JsonApiToOne
	// @JsonApiIncludeByDefault
	// @ManyToOne(fetch = FetchType.LAZY)
	// @JoinColumn(name = "consultway_id", foreignKey = @ForeignKey(name =
	// "null"))
	// @Fetch(FetchMode.JOIN) //huibati
	@JsonApiToMany
	@JsonApiIncludeByDefault
	@ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinTable(name = "tnb_consult_adv", joinColumns = { @JoinColumn(name = "consult_id",
			nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) },
			inverseJoinColumns = { @JoinColumn(name = "advway_id", nullable = false,
					updatable = false, foreignKey = @ForeignKey(name = "null")) })
	@Fetch(FetchMode.JOIN)
	public List<Dicttype> getAdvWay() {
		return advWay;
	}

	public void setAdvWay(List<Dicttype> advWay) {
		this.advWay = advWay;
	}

	@Column(name = "appointment_time")
	public Integer getAppointmentDate() {
		return appointmentDate;
	}

	public void setAppointmentDate(Integer appointmentDate) {
		this.appointmentDate = appointmentDate;
	}
	@Column(name = "sign")
	public Integer getSign() {
		return sign;
	}
	
	public void setSign(Integer sign) {
		this.sign = sign;
	}

	@Column(name = "care")
	public String getCare() {
		return care;
	}

	public void setCare(String care) {
		this.care = care;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "consultchannel_id", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getConsultChannel() {
		return consultChannel;
	}

	public void setConsultChannel(Dicttype consultChannel) {
		this.consultChannel = consultChannel;
	}

	// public String getChannelDetAiled() {
	// return channelDetAiled;
	// }
	//
	// public void setChannelDetAiled(String channelDetAiled) {
	// this.channelDetAiled = channelDetAiled;
	// }

	@Column(name = "diet_requirements")
	public String getDietRequirements() {
		return dietRequirements;
	}

	public void setDietRequirements(String dietRequirements) {
		this.dietRequirements = dietRequirements;
	}

	// public Dicttype getDiningStandard() {
	// return diningStandard;
	// }
	//
	// public void setDiningStandard(Dicttype diningStandard) {
	// this.diningStandard = diningStandard;
	// }
	@Column(name = "discontent")
	public String getDiscontent() {
		return discontent;
	}

	public void setDiscontent(String discontent) {
		this.discontent = discontent;
	}

	@Column(name = "customer_address")
	public String getCustomerAddr() {
		return customerAddr;
	}

	public void setCustomerAddr(String customerAddr) {
		this.customerAddr = customerAddr;
	}

	@Column(name = "customer_birth")
	public String getCustomerBrith() {
		return customerBrith;
	}

	public void setCustomerBrith(String customerBrith) {
		this.customerBrith = customerBrith;
	}

	@Column(name = "customer_cardcode")
	public String getCustomerCardCode() {
		return customerCardCode;
	}

	public void setCustomerCardCode(String customerCardCode) {
		this.customerCardCode = customerCardCode;
	}

	@Column(name = "customer_consumingability")
	public String getCustomerConsumingAbility() {
		return customerConsumingAbility;
	}

	public void setCustomerConsumingAbility(String customerConsumingAbility) {
		this.customerConsumingAbility = customerConsumingAbility;
	}

	@Column(name = "customer_tel")
	public String getCustomerTel() {
		return customerTel;
	}

	public void setCustomerTel(String cunstomerTel) {
		this.customerTel = cunstomerTel;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customer_educationid", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getCustomerEducation() {
		return customerEducation;
	}

	public void setCustomerEducation(Dicttype customerEducation) {
		this.customerEducation = customerEducation;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cunstomer_genderid", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getCustomerGender() {
		return customerGender;
	}

	public void setCustomerGender(Dicttype customerGender) {
		this.customerGender = customerGender;
	}

	@Column(name = "customer_name")
	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customer_nativeid", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getCustomerNative() {
		return customerNative;
	}

	public void setCustomerNative(Dicttype customerNative) {
		this.customerNative = customerNative;
	}

	@Column(name = "customer_ps")
	public String getCustomerPS() {
		return customerPS;
	}

	public void setCustomerPS(String customerPS) {
		this.customerPS = customerPS;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customer_relationid", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getConsultRelation() {
		return consultRelation;
	}

	public void setConsultRelation(Dicttype consultRelation) {
		this.consultRelation = consultRelation;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cunstomer_selfcareabilityid", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getCustomerSelfCareAbility() {
		return customerSelfCareAbility;
	}

	public void setCustomerSelfCareAbility(Dicttype customerSelfCareAbility) {
		this.customerSelfCareAbility = customerSelfCareAbility;
	}

	// public BackInfo getBackInfo() {
	// return backInfo;
	// }
	//
	// public void setInfoID(BackInfo info) {
	// this.infoID = info;
	// }

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cunstomer_nationalityid", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getCustomerNationality() {
		return customerNationality;
	}

	public void setCustomerNationality(Dicttype customerNationality) {
		this.customerNationality = customerNationality;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "nursinggrade_id", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getNursingGrade() {
		return nursingGrade;
	}

	public void setNursingGrade(Dicttype nursingGrade) {
		this.nursingGrade = nursingGrade;
	}

	@Column(name = "occupancyintent")
	public String getOccupancyIntent() {
		return occupancyIntent;
	}

	public void setOccupancyIntent(String occupancyIntent) {
		this.occupancyIntent = occupancyIntent;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "consultstatus_id", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getConsultStatus() {
		return consultStatus;
	}

	public void setConsultStatus(Dicttype consultStatus) {
		this.consultStatus = consultStatus;
	}

	@Column(name = "other_requirements")
	public String getOtherRequirements() {
		return otherRequirements;
	}

	public void setOtherRequirements(String otherRequirements) {
		this.otherRequirements = otherRequirements;
	}

	@Column(name = "psychologicalprice")
	public String getPsychologicalPrice() {
		return psychologicalPrice;
	}

	public void setPsychologicalPrice(String psychologicalPrice) {
		this.psychologicalPrice = psychologicalPrice;
	}

	@Column(name = "review")
	public String getReview() {
		return review;
	}

	public void setReview(String review) {
		this.review = review;
	}

	@Column(name = "room_requirements")
	public String getRoomRequirements() {
		return roomRequirements;
	}

	public void setRoomRequirements(String roomRequirements) {
		this.roomRequirements = roomRequirements;
	}

	@Column(name = "service_requirements")
	public String getServiceRequirements() {
		return serviceRequirements;
	}

	public void setServiceRequirements(String serviceRequirements) {
		this.serviceRequirements = serviceRequirements;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "heart_userid", foreignKey = @ForeignKey(name = "null"))
	public Employee getHeartStaff() {
		return heartStaff;
	}

	public void setHeartStaff(Employee heartStaff) {
		this.heartStaff = heartStaff;
	}

	@JsonApiToOne
	@ManyToOne
	@JoinColumn(name = "receive_userid", foreignKey = @ForeignKey(name = "null"))
	public Employee getReceiveStaff() {
		return receiveStaff;
	}

	public void setReceiveStaff(Employee receiveStaff) {
		this.receiveStaff = receiveStaff;
	}

	// public Dicttype getStatus() {
	// return status;
	// }
	//
	// public void setStatus(Dicttype status) {
	// this.status = status;
	// }
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "roomType", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getRoomType() {
		return roomType;
	}

	public void setRoomType(Dicttype roomType) {
		this.roomType = roomType;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "dementiaType", foreignKey = @ForeignKey(name = "null"))
	@Fetch(FetchMode.JOIN)
	public Dicttype getDementiaType() {
		return dementiaType;
	}

	public void setDementiaType(Dicttype dementiaType) {
		this.dementiaType = dementiaType;
	}
}